package com.lj.queue.param;

import com.lj.queue.entity.DelayQueueMeta;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import com.lj.common.utils.EnumUtils;
import com.lj.queue.enums.TimeUnits;

/**
 * <p>
 * 延迟队列数据表 更新参数
 * </p>
 *
 * @author lj
 * @since 2025-07-18 17:15:03
 */
@Data
@Schema(description = "延迟队列数据表 更新参数")
public class DelayQueueMetaUpdateParam {

    @Schema(description = "主键id")
    private Long id;

    @Schema(description = "预加载间隔")
    private Long preloadDistance;

    @Schema(description = "预加载时长")
    private Long preloadDuration;

    @Schema(description = "时间单位 参考字典: TimeUnits")
    private Integer timeUnit;

    public DelayQueueMeta toEntity() {
        DelayQueueMeta entity = new DelayQueueMeta();
        entity.setId(id);
        entity.setPreloadDistance(preloadDistance);
        entity.setPreloadDuration(preloadDuration);
        entity.setTimeUnit(EnumUtils.getByValue(TimeUnits.class, timeUnit));
        return entity;
    }
}
